import { defineStore } from "pinia";
import myRequest from '@/service/request/index'
import { getHomeHotSuggests, getCategories, getHouselistData } from "@/service";

const useHomeStore = defineStore("home", {
  state: () => ({
    hotSuggests:[],
    categories: [],
    houselist:[],
    currentPage: 1
  }),
  actions:{
    async fetchHotSuggestData() {
      const res = await getHomeHotSuggests()
      this.hotSuggests = res.data
    },
    async fetchCategoriesData() {
      const res = await getCategories()
      this.categories = res.data
    },
    async fetchHouselistData() {
      const res = await getHouselistData(this.currentPage)
      console.log(res)
      this.houselist.push(...res.data)
      this.currentPage++
    }
  }

})
export default useHomeStore